using System;
using UnityEngine;

[RequireComponent(typeof(Renderer))]
public class BGStretch : MonoBehaviour
{
	private void Start()
	{
		this.StretchScale();
	}

	private void StretchScale()
	{
		Texture mainTexture = base.GetComponent<Renderer>().sharedMaterial.mainTexture;
		Rect screenExtents = this.cam.ScreenExtents;
		float num = (float)mainTexture.width / (float)mainTexture.height;
		float num2 = screenExtents.width / screenExtents.height;
		if (num > num2)
		{
			base.transform.localScale = new Vector3(screenExtents.height * num, screenExtents.height, 1f);
		}
		else
		{
			base.transform.localScale = new Vector3(screenExtents.width, screenExtents.width / num, 1f);
		}
	}

	public tk2dCamera cam;
}
